package br.edu.unirn.interceptor;

import java.io.Serializable;

import org.hibernate.EmptyInterceptor;
import org.hibernate.type.Type;

public class LogDatabase extends EmptyInterceptor {

	private static final long serialVersionUID = 1L;

	@Override
	public boolean onLoad(Object entity, Serializable id, Object[] state,
			String[] propertyNames, Type[] types) {
		System.out.println("Carregando: "
				+ entity.getClass().getCanonicalName());
		System.out.println("Buscando: " + id);
		for (int i = 0; i < state.length; i++) {
			System.out.print("Propriedade: " + propertyNames[i]);
			System.out.println(" Estado: " + state[i]);

		}
		return super.onLoad(entity, id, state, propertyNames, types);
	}

	@Override
	public boolean onSave(Object entity, Serializable id, Object[] state,
			String[] propertyNames, Type[] types) {
		return super.onSave(entity, id, state, propertyNames, types);
	}

	@Override
	public void onDelete(Object entity, Serializable id, Object[] state,
			String[] propertyNames, Type[] types) {
		super.onDelete(entity, id, state, propertyNames, types);
	}
}
